<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>添加业务名称</title>
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<script type="text/javascript" src="../resources/scripts/ext-base.js"></script>
	<script type="text/javascript" src="../resources/scripts/ext-basex.js"></script>
	<script type="text/javascript" src="../resources/scripts/ext-all-debug.js"></script>
	<script type="text/javascript" src="../resources/scripts/utils.js"></script>
	<link href="../resources/styles/ext-all.css" rel="stylesheet" type="text/css"/>
	<link href="../resources/styles/screen.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
  </body>
  
<script type="text/javascript">
Ext.namespace("Report.Add");
Report.Add.panel = function (){
	this.addBusinessName1 = new Ext.form.TextField({fieldLabel: '业务名称1', width:130 });
	this.addBusinessName2 = new Ext.form.TextField({fieldLabel: '业务名称2', width:130 });
	this.addBusinessName3 = new Ext.form.TextField({fieldLabel: '业务名称3', width:130 });
	this.colseButton = new Ext.Button({
		text:"关闭",
		handler:function(){
			window.close();
		},
		scope:this
	});
	this.subButton = new Ext.Button({
		text:"添加",
		handler: this.addName,
		scope:this
	});
	this.addPanel = new Ext.form.FormPanel({
		title:'添加业务名称',
		autoWidth: true,
		labelWidth: 90,
		labelAlign: 'right',
		region: 'north',
		layout: 'table',
		height: 200,
		frame: true,
		layoutConfig: {columns: 1},
		style: {algin:'center'},
		items: [
					{layout: 'form',items: [this.addBusinessName1 ]},
					{layout: 'form',items: [this.addBusinessName2 ]},
					{layout: 'form',items: [this.addBusinessName3 ]}
			]
	});
	Report.Add.panel.superclass.constructor.call(this,{
		width:280,
		height:200,
		modal:true,
		autoScroll:false,
		closeAction:'hide',
		buttonAlign:'right',
		buttons:[this.subButton, this.colseButton ],
		items:[this.addPanel],
		listeners:{
		}
	});
};
Ext.extend(Report.Add.panel, Ext.Window, {
	addName: function(){
		var addBusinessName1 = this.addBusinessName1.getValue();
		var addBusinessName2 = this.addBusinessName2.getValue();
		var addBusinessName3 = this.addBusinessName3.getValue();
		if (addBusinessName1 =='' && addBusinessName2 =='' && addBusinessName3 ==''){
			alert("请输入业务名称!");
			return;
		} else if ((addBusinessName1 == addBusinessName2 && addBusinessName1 !='') 
				||(addBusinessName2 == addBusinessName3 && addBusinessName3 !='' )
				|| addBusinessName1 == addBusinessName3 && addBusinessName1 !=''){
			alert("业务名称不能重复!");
			return;
		} else if (addBusinessName1.length>50 || addBusinessName2.length>50 || addBusinessName3.length>50 ){
			alert("业务名称过长!");
			return;
		} else {
			Ext.Ajax.request({
				url: '../report/checkBusinessName.form',
				method: 'POST',
				params: {
					name1: addBusinessName1,
					name2: addBusinessName2,
					name3: addBusinessName3
				},
				scope: this,
				success:function(rsp){
					var result = Ext.util.JSON.decode(rsp.responseText).result;
					// 如果业务名称已存在则提示，不存在则将输入的内容插入数据库中
					if (result == '1' || result == '2' || result == '3'){
						alert("业务名称"+result+"已在数据库中存在!");
						return;
					}else {
						Ext.Ajax.request({
							url: '../report/addBusinessName.form',
							method: 'POST',
							params: {
								name1: addBusinessName1,
								name2: addBusinessName2,
								name3: addBusinessName3
							},
							scope: this,
							success:function(rsp){
								alert("添加成功!");
								history.go(0);
							},
							failure:function(){
							}
						});
					}
				}
			});
		}
	}
});

Ext.onReady(function(){
    Ext.QuickTips.init();
    Ext.BLANK_IMAGE_URL = '../resources/images/default/s.gif';
   	Report.Add.panel.instance = new Report.Add.panel();
    Report.Add.panel.instance.show();
});
</script>
</html>
